/**
 * 
 */
package com.dragon.modules.yuegou.client.wechat.response;

import com.dragon.common.exception.DragonException;
import com.dragon.modules.yuegou.client.wechat.model.Good;
import com.dragon.modules.yuegou.enums.code.LiveCode;
import com.dragon.modules.yuegou.enums.code.LiveUtils;

import java.io.Serializable;
import java.util.List;

/**
 * @author 获取商品信息响应
 *
 */
public class GetgoodswarehouseResponse implements Serializable{
	private static final long serialVersionUID = -2014277555577418881L;

	//响应值
	private Integer errcode;
	
	//响应内容
	private String errmsg;
	
	private Integer total;
	
	//商品信息
	private List<Good> goods;

	public Integer getErrcode() {
		return errcode;
	}

	public void setErrcode(Integer errcode) {
		this.errcode = errcode;
	}

	public String getErrmsg() {
		return errmsg;
	}

	public void setErrmsg(String errmsg) {
		this.errmsg = errmsg;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

	public List<Good> getGoods() {
		return goods;
	}

	public void setGoods(List<Good> goods) {
		this.goods = goods;
	}
	
	// 响应较验
	public void check() {
		if (null != errcode && errcode.intValue() != 0) {
			LiveCode liveCode = LiveUtils.getLiveCode(errcode);
			if (liveCode == null) {
				throw new DragonException(LiveCode.LIVE_ERROR.getCode(),String.format(LiveCode.LIVE_ERROR.getMessage(),errmsg));
			}else {
				throw new DragonException(liveCode);
			}
			
		}
	}
	
}
